﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace ServiceBase
{
    public static class BaseFunction
    {
        /// <summary>
        /// 判断某像素是否是空白
        /// </summary>
        /// <param name="map"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        public static bool IsEmptyPixel(Bitmap map, int x, int y)
        {
            Color c = map.GetPixel(x, y);
            if (c.ToArgb() == Color.White.ToArgb() || c.IsEmpty)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 判断某列是否为空白列
        /// </summary>
        /// <param name="map"></param>
        /// <param name="x">起点X</param>
        /// <param name="y">起点Y</param>
        /// <param name="height">扫描线的高度</param>
        /// <returns></returns>
        public static bool IsEmptyColumn(Bitmap map, int x, int y, int height)
        {
            for (int i = 0; i < height; i++)
            {
                if (!IsEmptyPixel(map,x,y + i))
                {
                    return false;
                }
            }
            return true;
        }

        /// <summary>
        /// 判断某列是否为空白列
        /// </summary>
        /// <param name="map"></param>
        /// <param name="x">起点X</param>
        /// <param name="y">起点Y</param>
        /// <param name="height">扫描线的高度</param>
        /// <returns></returns>
        public static bool IsEmptyColumn(Bitmap map, int x)
        {
            return IsEmptyColumn(map,x,0,map.Height);
        }
    }
}